<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" th:href="@{frame/layui/css/layui.css}">
    <link rel="stylesheet"  th:href="@{frame/static/css/style.css}">
    <link rel="icon" th:href="@{frame/static/image/code.png}">
</head>
<body>

<div class="login-main">
    <header class="layui-elip">后台登录</header>
    <form class="layui-form">
        <div class="layui-input-inline">
            <input type="text" name="loginname" required lay-verify="required" placeholder="账号" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="loginpwd" required lay-verify="required" placeholder="密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline login-btn">
            <button type="submit" lay-submit class="layui-btn" lay-filter="*">登录</button>
        </div>
        <hr/>
        <!--<div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-primary">QQ登录</button>
        </div>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-normal">微信登录</button>
        </div>-->
        <p><a href="javascript:;" class="fl">立即注册</a><a href="javascript:;" class="fr">忘记密码？</a></p>
    </form>
</div>


<script src="../../../static/frame/layui/layui.js" th:src="@{frame/layui/layui.js}"></script>
<script type="text/javascript">
    layui.use(['form'], function () {

        // 操作对象
        var form = layui.form
                , $ = layui.jquery;

        // you code ...
        form.on('submit(*)', function (data) {
            $.ajax({
                url: "/doLogin",
                dataType: "json",
                data: data.field,
                type: "post",
                success: function (data) {
                    if (data.code == 500) {
                        layer.msg(data.msg, {icon: 2, anim: 6});
                    }  if (data.code == 200) {
                        location.href = "/mgr";
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });


    });
</script>
</body>
</html>